<?php

declare(strict_types=1);

namespace App\Controller;

use Hyperf\Crontab\Annotation\Crontab;
use App\Model\User;

class CrontabController extends AbstractController
{

    /**
     * @Crontab(rule="00 00 1 * *", memo="用户积分转星币脚本")
     * 用户积分转星币脚本
     */
    public function user_points_star_currency()
    {
        $userList = User::query()->get()->toArray();
        foreach($userList as $val)
        {
            $star_currency = $val['star_currency'] + $val['points'];
            User::query()->where('id', $val['id'])->update(['star_currency' => $star_currency, 'points' => 0]);
        }
    }
    
}
